﻿#pragma once

#include "SMTData.h"
#include "SMTBasics.h"
#include <QLineEdit>
#include <QLabel>

class SMTOperatorGraphics;
class OcrSMTSettingPage;
class SMTGraphicElement;
class QColorl;
class SMTShape;
class SMTOperator;
class SMTVariableArray;
class SMTButtonBox;
class SMTSpinBox;
class SMTSwitchButton;

namespace opt_smt
{
	class SmtUiUtils
	{
	public:
		SmtUiUtils();
		~SmtUiUtils();
		SMTOperatorGraphics* mOperator;

		void setOperatorGraphics(SMTOperatorGraphics* graphicOperator);
		void handleInitUI(SMTVariableArray& m_paraInput, int index, SMTButtonBox* pWidget);
		void handleInitUI(SMTVariableArray& m_paraInput, int index, SMTSpinBox* pWidget);
		void handleInitUI(SMTVariableArray& m_paraInput, int index, SMTSwitchButton* pWidget);
		void handleInitUI(SMTOperator* m_opr, QComboBox* pWidget, int index);

		/// <summary>
		/// get aiServiceStatus Status
		/// </summary>
		/// <param name="opr"></param>
		/// <param name="idx"></param>
		/// <returns></returns>
		bool getAiServiceStatus(SMTOperator* opr, int idx);

		/// <summary>
		/// set aiServiceStatus Status
		/// </summary>
		/// <param name="opr"></param>
		/// <param name="idx"></param>
		/// <param name="ok"></param>
		void setAiServiceStatus(SMTOperator* opr, int idx, bool ok);

		/// <summary>
		/// send req and get Ai infer Url
		/// </summary>
		/// <param name="sceneName">scene Name</param>
		/// <param name="productName">product Name</param>
		/// <param name="pOpr">Oprator Pointer</param>
		/// <param name="idxVarInOfAiServiceStatus">index of AiServiceStatus in ParamInput</param>
		/// <param name="lineAiUrl">lineAiUrl Qt Widget Pointer</param>
		/// <param name="lineTaskName">lineTaskName Qt Widget Pointer</param>
		/// <param name="lineProjectName">lineProjectName Qt Widget Pointer</param>
		/// <param name="lblStatusLight">lblStatusLight Qt Widget Pointer</param>
		void getAiUrl(QString sceneName, 
			QString productName, 
			SMTOperator* pOpr, 
			int idxVarInOfAiServiceStatus, 
			QLineEdit* lineAiUrl, 
			QLineEdit* lineTaskName, 
			QLineEdit* lineProjectName, 
			QLabel* lblStatusLight);

		/// <summary>
		/// send req and fix Ai infer Url
		/// </summary>
		/// <param name="sceneName">scene Name</param>
		/// <param name="productName">product Name</param>
		/// <param name="pOpr">Oprator Pointer</param>
		/// <param name="idxVarInOfAiServiceStatus">index of AiServiceStatus in ParamInput</param>
		/// <param name="lineAiUrl">lineAiUrl Qt Widget Pointer</param>
		/// <param name="lineTaskName">lineTaskName Qt Widget Pointer</param>
		/// <param name="lineProjectName">lineProjectName Qt Widget Pointer</param>
		/// <param name="lblStatusLight">lblStatusLight Qt Widget Pointer</param>
		void fixAiUrl(QString sceneName, 
			QString productName, 
			SMTOperator* pOpr, 
			int idxVarInOfAiServiceStatus, 
			QLineEdit* lineAiUrl, 
			QLineEdit* lineTaskName, 
			QLineEdit* lineProjectName, 
			QLabel* lblStatusLight);

		/// <summary>
		/// draw shape on page,you can set r,g,b of OK and transparency
		/// </summary>
		/// <param name="m_graphics"></param>
		/// <param name="index"></param>
		/// <param name="okFlag"></param>
		/// <param name="shapeArray"></param>
		/// <param name="smtShapeType"></param>
		/// <param name="ok_r"></param>
		/// <param name="ok_g"></param>
		/// <param name="ok_b"></param>
		/// <param name="ok_alpha"></param>
		void drawShapeElem(SMTOperatorGraphics& m_graphics, int index, bool okFlag, SMTShapeArray& shapeArray, SMTShape::SMTShapeType smtShapeType, char ok_r, char ok_g, char ok_b, char ok_alpha);

		/// <summary>
		/// draw shape on page
		/// </summary>
		/// <param name="m_graphics"></param>
		/// <param name="index"></param>
		/// <param name="okFlag"></param>
		/// <param name="shapeArray"></param>
		/// <param name="smtShapeType"></param>
		void drawShapeElem(SMTOperatorGraphics& m_graphics, int index, bool okFlag, SMTShapeArray& shapeArray, SMTShape::SMTShapeType smtShapeType);

		/// <summary>
		/// draw shape on page,you can set r,g,b of OK and transparency
		/// </summary>
		/// <param name="m_graphics"></param>
		/// <param name="index"></param>
		/// <param name="okFlag"></param>
		/// <param name="shapeArray"></param>
		/// <param name="ok_r"></param>
		/// <param name="ok_g"></param>
		/// <param name="ok_b"></param>
		/// <param name="alpha"></param>
		void drawRegionElem(SMTOperatorGraphics& m_graphics, int index, bool okFlag, SMTShapeArray& shapeArray, char ok_r, char ok_g, char ok_b, char alpha);
		
		/// <summary>
		/// draw shape on page,you can set transparency
		/// </summary>
		/// <param name="m_graphics"></param>
		/// <param name="index"></param>
		/// <param name="okFlag"></param>
		/// <param name="shapeArray"></param>
		/// <param name="alpha">transparency</param>
		void drawRegionElem(SMTOperatorGraphics& m_graphics, int index, bool okFlag, SMTShapeArray& shapeArray, char alpha);

		/// <summary>
		/// draw label text on page,you can set r,g,b of OK and transparency
		/// </summary>
		/// <param name="m_graphics"></param>
		/// <param name="index"></param>
		/// <param name="okFlag"></param>
		/// <param name="topLeftPointArray"></param>
		/// <param name="labelNameArray"></param>
		/// <param name="ok_r"></param>
		/// <param name="ok_g"></param>
		/// <param name="ok_b"></param>
		/// <param name="ok_alpha"></param>
		void drawLabelElem(SMTOperatorGraphics& m_graphics, int index, bool okFlag, SMTPointArray& topLeftPointArray, SMTStringArray& labelNameArray, char ok_r, char ok_g, char ok_b, char ok_alpha);

		/// <summary>
		/// draw label text on page
		/// </summary>
		/// <param name="m_graphics"></param>
		/// <param name="index"></param>
		/// <param name="okFlag"></param>
		/// <param name="topLeftPointArray"></param>
		/// <param name="labelNameArray"></param>
		void drawLabelElem(SMTOperatorGraphics& m_graphics, int index, bool okFlag, SMTPointArray& topLeftPointArray, SMTStringArray& labelNameArray);
		void clearGraphicElem(SMTOperatorGraphics& m_graphics, int index);
	private:
		void getImageDataInputFromOpr(SMTOperator* m_opr);
	};
}
